package com.lhb.boyixue.user.config;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.lhb.boyixue.user.model.Question;

import java.io.File;
import java.io.IOException;

public class JsonFileReader {
    private static final ObjectMapper mapper = new ObjectMapper();

    public static void main(String[] args) {
        
        // 3. 流式处理大文件
        processLargeFile();
    }



    private static void processLargeFile() {
        try (JsonParser parser = mapper.getFactory().createParser(new File("bigdata.json"))) {
            if (parser.nextToken() == JsonToken.START_ARRAY) {
                while (parser.nextToken() != JsonToken.END_ARRAY) {
                    Question question = parser.readValueAs(Question.class);
                    // 处理每个用户对象
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}